-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cache the collection schema, only read from vatstore once per crank #7333
Conversation
@FUDCo the last commit changes the serialized So two questions for you to think about:
A performance note: this approach does either zero or one reads of @mhofman this ought to remove the gc-sensitivity due to collections being collected and then reanimated. And #7138 removed another. I think there's one known source of sensitivity for me to try to fix, involving KindHandles being reanimated (the other part of #7142). |
oops, something is still broken, will re-submit when ready |
10cc46d
to
91f525f
Compare
Ok I went ahead and changed the serialized schemata object to be empty if there were no keyShape/valueShape constraints given. In practice, there's always a keyShape, because the default is I'm storing |
Quick question: is there any reason not to merge the schemata and label vatStore entries into a single one? Especially now that we have a record for the schemata. |
I think that'd be fine. We've got two mutable metadata keys ( @FUDCo can you remember why they were split? |
I don't think there was a deep reason. Mainly, I think, to avoid having to parse the value to separate two relatively unrelated pieces of information from each other. |
Cool, thanks. Ok, now that we're reading them both at the same time (schemata, to build the keyShape/valueShape checkers, and label, to build the error messages emitted if those checkers fail), it'll save a vatstore read to merge them together. I'll add a commit to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is OK, but there are a few points I'm unclear on that I'd like to be clear on before approving.
return harden({ keyShape, valueShape, label, schemataCD }); | ||
}; | ||
/** @type {(collectionID: string, value: SchemaCacheValue) => void } */ | ||
const writeBacking = (collectionID, value) => { | ||
const { label, schemataCD } = value; | ||
const schemataKey = prefixc(collectionID, '|schemata'); | ||
const schemataValue = JSON.stringify(schemataCD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return keyShape
, valueShape
, AND schemataCD
from the read but stringify schemataCD
in the write? If the consumer needs the shapes, having the schemataCD
doesn't help, and when writing the producer (presumably) generates the keyShape
and valueShape
values and shouldn't concerned with how they're encoded. Am I missing something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is preparation for #7321 (PR #7334), which needs to know about any slots (vrefs) in the serialized keyShape/valueShape. When the collection is deleted, rather than re-serialize those values (to learn the vrefs, so we can feed them to vrm.removeReachableVref
, to decrement their refcounts), we keep the original serialized forms around. The memory overhead of retaining the serialized capdata is pretty small, and it didn't occur to me to trust that serialization would return the same values as the original.. felt more appropriate to retain the original instead.
The only time we write to the schemaCache
is when a collection is first created, and at that time we also have the serialized capdata available (again, as anticipation for #7334, which needs to increment refcounts for everything therein).
91f525f
to
2685344
Compare
edcb932
to
082f244
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well OK then
082f244
to
83155ef
Compare
49c6e6b
to
8b58027
Compare
83155ef
to
8a3ccc0
Compare
8b58027
to
d5114d2
Compare
8a3ccc0
to
09a7d00
Compare
d5114d2
to
8316eb9
Compare
This removes `deleteAllVirtualCollections`, and the in-RAM `allCollectionObjIDs` Set of all collectionIDs which supported it. Once upon a time, `stopVat` called `deleteAllVirtualCollections` to delete the vatstore data for all non-durable virtual collections. We removed responsibility for deleting virtual data from the vat (and stopped calling `stopVat` altogether) in the interests of reducing upgrade risk, and improving upgrade performance, despite the fact that this will cause a DB storage leak during upgrade (we figure we can find a way to fix that later, and disk is cheap). Now that `deleteAllVirtualCollections` is gone, we don't need to spend the RAM on each collection, which violated our high-cardinality design rules anyways. refs #5058
This changes the collectionManager to keep the per-collection metadata (keyShape, valueShape, label) in a cache. Like the VOM's dataCache, this `schemaCache` is populated at most once per crank, and flushed at the end of every crank. This removes the GC-sensitive syscalls that used to fetch the metadata when userspace caused a collection to be reanimated. Instead, the cache is read when userspace invokes a collection method that needs the data (most of them, to validate keys or values), regardless of whether the collection Representative remains in RAM or not. It also changes the serialized form of the schemata to be an object like `{ keyShape, valueShape }` instead of an array like `[keyShape, valueShape]`. If the constraints are missing, the object is empty, which is smaller to serialize. I'm also thinking this might make it more extensible. closes #6360
Virtual collections need to record a label and a keyShape/valueShape schema. Previously these were kept in two separate vatstore keys, `|label` and `|schemata`. With this change, they're both stored in the `|schemata` key. This should reduce the number of vatstore reads necessary to work with a collection.
09a7d00
to
2faa0a3
Compare
This changes the collectionManager to keep the per-collection
metadata (keyShape, valueShape, label) in a cache. Like the VOM's
dataCache, this
schemaCache
is populated at most once per crank, andflushed at the end of every crank. This removes the GC-sensitive
syscalls that used to fetch the metadata when userspace caused a
collection to be reanimated. Instead, the cache is read when userspace
invokes a collection method that needs the data (most of them, to
validate keys or values), regardless of whether the collection
Representative remains in RAM or not.
It also removes the now-unused in-RAM list of all collections, which used to support
deleteAllVirtualCollections
, called fromstopVat
.closes #6360
refs #5058
closes #7142